/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package smary.ejb.stateless;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;

/**
 *
 * @author ACANPOWER
 */
@Stateless
public class EncryptionUnit implements EncryptionUnitLocal {

    @Override
    public String stringToMD5(String tobeEncrypted) {
        try {
            MessageDigest m = MessageDigest.getInstance("MD5");
            byte[] data = tobeEncrypted.getBytes();
            m.update(data,0,data.length);
            BigInteger i = new BigInteger(1,m.digest());
            return String.format("%1$032X", i);
            
        } catch (NoSuchAlgorithmException ex) {
            Logger.getLogger(EncryptionUnit.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
        
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    
}
